package com.example.provider;

import java.util.List;
import com.example.model.PinYin;
import com.example.pinyin.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PinyinAdapter extends BaseAdapter {
	
	public List<PinYin> mList;
	public ViewHolder mViewHolder;
	public LayoutInflater mLayoutInflater;
	public Context mContext;
	public String pinyin;
	public String way;
	public String res;
	
	public PinyinAdapter(Context context,List<PinYin> list){
		this.mLayoutInflater=LayoutInflater.from(context);
		this.mContext=context;
		this.mList=list;
	}

	@Override
	public int getCount() {
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
	class ViewHolder{
		public TextView mZimu;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView=mLayoutInflater.inflate(R.layout.pinyin_adapter_item, null);
			mViewHolder = new ViewHolder();
			mViewHolder.mZimu=(TextView) convertView.findViewById(R.id.btn_zimu);
			convertView.setTag(mViewHolder);
		}else{
			mViewHolder=(ViewHolder)convertView.getTag();
		}
		pinyin=mList.get(position).getName();
		mViewHolder.mZimu.setText(pinyin);
		
		return convertView;
	}

}
